How can I return just the first line of the Object Text?

How can I return just the first line of the Object Text?
As far as I can tell, Object Text is Rich Text. What functions would I use?

Second question: Where are the functions like probeRichAttr and so on documented? I have not been able to find any kind of documentation of these functions.
SystemAdmin - Thu Oct 18 19:48:23 EDT 2012

Re: How can I return just the first line of the Object Text?
SystemAdmin - Fri Oct 19 05:22:33 EDT 2012

Well, what do you mean by a line? The first line visible in DOORS main column or the first line ending in a return (paragraph)?

Through Object Text is stored internally as rich text, when you access the value by
 

string ObjectText = o."Object Text"

 

you get the plain text content. If you want to have the rich text, you have to use

 

 

string ObjectText = richText(o."Object Text")


or even

 

 

string ObjectText = richTextWithOle(o."Object Text")


On the probeAttr etc. functions: actually they are not documented anywhere, but they are defined in a DXL include file supplied with DOORS: <DOORS installation directory>\lib\dxl\utils\attrutil.inc

 

 

 

 

  • Pekka Mäkinen - http://www.softqa.eu/

 

 

Re: How can I return just the first line of the Object Text?
SystemAdmin - Fri Oct 19 07:15:01 EDT 2012

Object o = current()
Buffer aRichTextBuffer = create()
aRichTextBuffer = richTextWithOle(o."Object Text")
 
RichTextParagraph EachRichTextParagraph
for EachRichTextParagraph in (tempStringOf(aRichTextBuffer)) do
{
  print(EachRichTextParagraph.text)
  break
}
delete(aRichTextBuffer )
}

Re: How can I return just the first line of the Object Text?
SystemAdmin - Fri Oct 19 14:47:09 EDT 2012

SystemAdmin - Fri Oct 19 05:22:33 EDT 2012

Well, what do you mean by a line? The first line visible in DOORS main column or the first line ending in a return (paragraph)?

Through Object Text is stored internally as rich text, when you access the value by
 

string ObjectText = o."Object Text"

 

you get the plain text content. If you want to have the rich text, you have to use

 

 

string ObjectText = richText(o."Object Text")


or even

 

 

string ObjectText = richTextWithOle(o."Object Text")


On the probeAttr etc. functions: actually they are not documented anywhere, but they are defined in a DXL include file supplied with DOORS: <DOORS installation directory>\lib\dxl\utils\attrutil.inc

 

 

 

 

  • Pekka Mäkinen - http://www.softqa.eu/

 

 

I want to return the first line ending in a return. I guess I want RTF, because I want underlining and bold to be included. The script is based on what the analysis wizard generated - I'm not able to write scripts from scratch.

Here's what I've got. It returns nothing at the moment. What character should I search for instead of "\n" to find the position of the first return/newline/EOL/whatever?
 

OT = probeRichAttr_(othero,"Object Text", false)
                if (findPlainText (OT, "\n", offset, length, matchCase, reverse)) {
                    displayRich("\\pard " "Traced From: " OT[0:offset])
                }

 


Is it because Object Text contains RTF, but I'm using findPlainText?

 

Re: How can I return just the first line of the Object Text?
SystemAdmin - Fri Oct 19 14:48:30 EDT 2012

SystemAdmin - Fri Oct 19 07:15:01 EDT 2012

Object o = current()
Buffer aRichTextBuffer = create()
aRichTextBuffer = richTextWithOle(o."Object Text")
 
RichTextParagraph EachRichTextParagraph
for EachRichTextParagraph in (tempStringOf(aRichTextBuffer)) do
{
  print(EachRichTextParagraph.text)
  break
}
delete(aRichTextBuffer )
}

Thanks for your reply.
I tried pasting your script into position in my wizard-generated script, but it gave me some syntax errors, and I don't know how to fix them.

Re: How can I return just the first line of the Object Text?
SystemAdmin - Mon Oct 22 02:46:44 EDT 2012

SystemAdmin - Fri Oct 19 14:48:30 EDT 2012
Thanks for your reply.
I tried pasting your script into position in my wizard-generated script, but it gave me some syntax errors, and I don't know how to fix them.

Delete the last '}' character. It shouldn't be there.

Re: How can I return just the first line of the Object Text?
SystemAdmin - Mon Oct 22 14:24:19 EDT 2012

SystemAdmin - Mon Oct 22 02:46:44 EDT 2012
Delete the last '}' character. It shouldn't be there.

Now the code shows no errors afgter I click "Check". But now the code returns nothing. Here's the chunk in question.
 

MODULE = name(otherMod)
                if (isBaseline(otherVersion)) {
                    MODULE = MODULE " [" versionString(otherVersion) "]"
                }
                displayRich("\\pard " MODULE)
 
                IF_IDENTIFIER = probeRichAttr_(IF_PARENT_OBJECT,"Object Identifier", false)
                displayRich("\\pard ID: " IF_IDENTIFIER " (" IF_VnV_ED ")")
 
                IF_NAME = probeRichAttr_(IF_PARENT_OBJECT,"Object Heading", false)
                displayRich("\\pard " IF_NAME)
 
                IF_SPECIFIER = probeRichAttr_(IF_PARENT_OBJECT,"Responsible", false)
                displayRich("\\pard " "Specifier: " IF_SPECIFIER)
 
                s = probeRichAttr_(othero,"Object Text", false)
 
//                if (findPlainText (s, ":", offset, length, matchCase, reverse)) {
//                    displayRich("\\pard " "Traced From: " s[0:offset])
//                }
 
Object o = current()
Buffer aRichTextBuffer = create()
aRichTextBuffer = richTextWithOle(o."Object Text")
 
RichTextParagraph EachRichTextParagraph
for EachRichTextParagraph in (tempStringOf(aRichTextBuffer)) do
{
  print(EachRichTextParagraph.text)
  break
}
delete(aRichTextBuffer )
 
 
 
                IF_VERIFIER = probeRichAttr_(othero,"Responsible", false)
                displayRich("\\pard " "Verifier: " IF_VERIFIER )
 
                displayRich("\\pard " " ")

 


You can see where I commented out my original attempt to use 'findPlainText' to find a colon and cut it there. That works, but I don't want to cut at the colon, I want to find the end of the paragraph.

I pasted the suggested code in below, but now the output shows the module name, object id, heading, and the "responsible" value. After that, nothing is output. Could it be a problem with the contents of the Object Text?

I appreciate your continued help and patience.

 

Re: How can I return just the first line of the Object Text?
SystemAdmin - Tue Oct 23 03:58:09 EDT 2012

SystemAdmin - Mon Oct 22 14:24:19 EDT 2012

Now the code shows no errors afgter I click "Check". But now the code returns nothing. Here's the chunk in question.
 

MODULE = name(otherMod)
                if (isBaseline(otherVersion)) {
                    MODULE = MODULE " [" versionString(otherVersion) "]"
                }
                displayRich("\\pard " MODULE)
 
                IF_IDENTIFIER = probeRichAttr_(IF_PARENT_OBJECT,"Object Identifier", false)
                displayRich("\\pard ID: " IF_IDENTIFIER " (" IF_VnV_ED ")")
 
                IF_NAME = probeRichAttr_(IF_PARENT_OBJECT,"Object Heading", false)
                displayRich("\\pard " IF_NAME)
 
                IF_SPECIFIER = probeRichAttr_(IF_PARENT_OBJECT,"Responsible", false)
                displayRich("\\pard " "Specifier: " IF_SPECIFIER)
 
                s = probeRichAttr_(othero,"Object Text", false)
 
//                if (findPlainText (s, ":", offset, length, matchCase, reverse)) {
//                    displayRich("\\pard " "Traced From: " s[0:offset])
//                }
 
Object o = current()
Buffer aRichTextBuffer = create()
aRichTextBuffer = richTextWithOle(o."Object Text")
 
RichTextParagraph EachRichTextParagraph
for EachRichTextParagraph in (tempStringOf(aRichTextBuffer)) do
{
  print(EachRichTextParagraph.text)
  break
}
delete(aRichTextBuffer )
 
 
 
                IF_VERIFIER = probeRichAttr_(othero,"Responsible", false)
                displayRich("\\pard " "Verifier: " IF_VERIFIER )
 
                displayRich("\\pard " " ")

 


You can see where I commented out my original attempt to use 'findPlainText' to find a colon and cut it there. That works, but I don't want to cut at the colon, I want to find the end of the paragraph.

I pasted the suggested code in below, but now the output shows the module name, object id, heading, and the "responsible" value. After that, nothing is output. Could it be a problem with the contents of the Object Text?

I appreciate your continued help and patience.

 

It is getting the first paragraph of the 'current' object. That means the object that is selected in the GUI.
In layout DXL use 'obj' to reference the object.
Get rid of:

Object o = current()


Replace:

aRichTextBuffer = richTextWithOle(o."Object Text")


with:

 

 

aRichTextBuffer = richTextNoOle(obj."Object Text")



Next problem is you are printing, not displaying.

 

 

print(EachRichTextParagraph.text)

 

 

display(EachRichTextParagraph.text)



Also, when you use multiple display/displayRich statements, you do not need to put "\\pard " tags in.
You do need them to display multiple paragraphs with one display/displayRich statement.



 

 

display("Paragraph 1")
display("Paragraph 2")
display("Paragraph 3")

 

 

 

display("Paragraph 1\nParagraph 2\nParagraph 3")



Also, this code only gets the plaintext of the first paragraph.



 

 

Re: How can I return just the first line of the Object Text?
SystemAdmin - Tue Oct 23 04:50:56 EDT 2012

SystemAdmin - Mon Oct 22 14:24:19 EDT 2012

Now the code shows no errors afgter I click "Check". But now the code returns nothing. Here's the chunk in question.
 

MODULE = name(otherMod)
                if (isBaseline(otherVersion)) {
                    MODULE = MODULE " [" versionString(otherVersion) "]"
                }
                displayRich("\\pard " MODULE)
 
                IF_IDENTIFIER = probeRichAttr_(IF_PARENT_OBJECT,"Object Identifier", false)
                displayRich("\\pard ID: " IF_IDENTIFIER " (" IF_VnV_ED ")")
 
                IF_NAME = probeRichAttr_(IF_PARENT_OBJECT,"Object Heading", false)
                displayRich("\\pard " IF_NAME)
 
                IF_SPECIFIER = probeRichAttr_(IF_PARENT_OBJECT,"Responsible", false)
                displayRich("\\pard " "Specifier: " IF_SPECIFIER)
 
                s = probeRichAttr_(othero,"Object Text", false)
 
//                if (findPlainText (s, ":", offset, length, matchCase, reverse)) {
//                    displayRich("\\pard " "Traced From: " s[0:offset])
//                }
 
Object o = current()
Buffer aRichTextBuffer = create()
aRichTextBuffer = richTextWithOle(o."Object Text")
 
RichTextParagraph EachRichTextParagraph
for EachRichTextParagraph in (tempStringOf(aRichTextBuffer)) do
{
  print(EachRichTextParagraph.text)
  break
}
delete(aRichTextBuffer )
 
 
 
                IF_VERIFIER = probeRichAttr_(othero,"Responsible", false)
                displayRich("\\pard " "Verifier: " IF_VERIFIER )
 
                displayRich("\\pard " " ")

 


You can see where I commented out my original attempt to use 'findPlainText' to find a colon and cut it there. That works, but I don't want to cut at the colon, I want to find the end of the paragraph.

I pasted the suggested code in below, but now the output shows the module name, object id, heading, and the "responsible" value. After that, nothing is output. Could it be a problem with the contents of the Object Text?

I appreciate your continued help and patience.

 

... and for richText use this:

Buffer aRichTextBuffer = create()
aRichTextBuffer = richTextWithOle(obj."Object Text")
 
Regexp aRegexp = regexp2("(.*?[^\\\\])(\\\\par[^d])")
 
if(aRegexp aRichTextBuffer) { 
    Buffer aSubBuffer = aRichTextBuffer[match 1]
        displayRich((tempStringOf(aSubBuffer)) "}")
        delete(aSubBuffer)
} else {
        displayRich((tempStringOf(aRichTextBuffer)))
}
 
delete(aRegexp)
delete(aRichTextBuffer)

 


Difficult to guarentee it will always work. I notice a bulleted paragraph loses the bullet.

 

Re: How can I return just the first line of the Object Text?
SystemAdmin - Tue Oct 23 17:38:47 EDT 2012

SystemAdmin - Tue Oct 23 03:58:09 EDT 2012

It is getting the first paragraph of the 'current' object. That means the object that is selected in the GUI.
In layout DXL use 'obj' to reference the object.
Get rid of:

Object o = current()


Replace:

aRichTextBuffer = richTextWithOle(o."Object Text")


with:

 

 

aRichTextBuffer = richTextNoOle(obj."Object Text")



Next problem is you are printing, not displaying.

 

 

print(EachRichTextParagraph.text)

 

 

display(EachRichTextParagraph.text)



Also, when you use multiple display/displayRich statements, you do not need to put "\\pard " tags in.
You do need them to display multiple paragraphs with one display/displayRich statement.



 

 

display("Paragraph 1")
display("Paragraph 2")
display("Paragraph 3")

 

 

 

display("Paragraph 1\nParagraph 2\nParagraph 3")



Also, this code only gets the plaintext of the first paragraph.



 

 

That did it. I had to change "obj" to "othero" so that it returned the first line of the Object Text of the linked object, rather than the current object. I wasn't clear in my initial request.

I don't understand the code, but it works. Can you recommend a good resource for learning DXL? The reference manual is no good for learning, only reference.

Also, in your response, you mention Layout DXL. Does that mean your original code was for use in Attribute DXL?

Thank you very much for your help,
Matthew

Re: How can I return just the first line of the Object Text?
SystemAdmin - Wed Oct 24 04:08:06 EDT 2012

SystemAdmin - Tue Oct 23 17:38:47 EDT 2012
That did it. I had to change "obj" to "othero" so that it returned the first line of the Object Text of the linked object, rather than the current object. I wasn't clear in my initial request.

I don't understand the code, but it works. Can you recommend a good resource for learning DXL? The reference manual is no good for learning, only reference.

Also, in your response, you mention Layout DXL. Does that mean your original code was for use in Attribute DXL?

Thank you very much for your help,
Matthew

I don't know of any DXL tutorials but I guess they must exist... I just learn by poking about with existing code and trying stuff out. Knowing c is a start as DXL is 'similar' to c. It has DOORS specific types added and certain c syntax relaxed (eg semicolons terminating lines and parenthesis around arguments are optional in DXL).

The original code was written for 'on demand' DXL. Paste it in the 'Tools - Edit DXL...' window of a module and click run.